<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            // await 等待  语法糖
            // await promise   『返回 promise 对象成功的结果值』
            // main  入口
            async function main() {
                //promise 对象
                let p = new Promise((resolve, reject) => {
                    setTimeout(() => {
                        reject("error");
                    }, 2000)
                });
                
                try {
                    let res = await p;
                    console.log(res);
                } catch (e) {
                    console.log(e)
                }
            }

            main();
        </script>
    </body>
</html>
